package io;
import java.io.File;
import model.Prescription;
import view.Designer;
/** * A class to encapsulate the importing of an XML document into the designer * @author Daniel Bond, Mohammed Abdullah, Gideon Pyzer * */
public class ImportXML {
	/**
	 * Import an XML file to create a prescription	 * @return true if the file imports successfully, false otherwise
	 */
	public static boolean importXML(){
		FileOpenDialog fod = new FileOpenDialog(new File("C:\\"));
		File file = fod.show();
		if (file != null)
		{
			xmlParser.getInstance().load(file.getPath());
			Designer designer = Designer.getInstance();
			designer.update();			
			return true;
		}
		return false;
	}
	/**
	 * Import an XML file to create a prescription
	 * @param filename the filename to import
	 */
	public static void importXML(File file)
	{
		xmlParser.getInstance().load(file.getAbsolutePath());
		Designer designer = Designer.getInstance();
		designer.update();
		Prescription.getInstance().setUnchanged();
		designer.updateTitle();
	}
}
